import VueRouter from "vue-router"
import routes from "./routes"
import Vue from "vue"
// import {islogin} from "../utils/auth"
// import {isloginBack} from "../utils/auth"

Vue.use(VueRouter)


//解决重复点击路由报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


let router = new VueRouter({
    mode:"history",
    routes,
})

// router.beforeEach((to,from,next)=>{
//     let isAuth = islogin()
//     let isAuthBack = isloginBack();
//     if(to.path === '/login'){
//         if(isAuth){
//             next('/test')
//         }else{
//             next()
//         }
//     }else{
//         if(isAuth){
//             next('/test')
//         }else{
//             next('/login')
//         }
//     }
// })

export default router